package ecom.servlets;

import ecom.beans.*;

import java.io.IOException;
import java.io.PrintWriter;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.naming.NamingException;
import javax.transaction.UserTransaction;


public class CaddyServlet extends HttpServlet {

  /**
     * Serializable class uid.
     */
    private static final long serialVersionUID = 6893863749912962928L;


    /**
     * Called by the server (via the service method) to allow a servlet to
     * handle a GET request.
     * @param request an HttpServletRequest object that contains the request
     * the client has made of the servlet
     * @param response an HttpServletResponse object that contains the
     * response the servlet sends to the client
     * @throws IOException if an input or output error is detected when the
     * servlet handles the GET request
     * @throws ServletException if the request for the GET could not be handled
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    	 HttpSession session = request.getSession(false);
    	 
    	 CustomerAccess caddy = (CustomerAccess)session.getAttribute("bd");
    	 String s = (String)(request.getParameter("article"));
    	 caddy.cartAddProduct(s);
    	 
    	 String cat = null;    		 
    	 
    	 getServletConfig().getServletContext().getRequestDispatcher("panier.jsp").forward(request,response);
    	
    }
    
    public  void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {

    	doGet(request,response);
    }
    
    
    
    
}

